#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

void print(int signo)
{
	printf("catch the signo %d\n",signo);
}

int main()
{
	signal(SIGINT,print);
	signal(SIGQUIT,print);
	signal(60,print);
	printf("pid=%d\n",getpid());
	printf("no mask\n");
	sleep(10);
	printf("begin mask\n");
	sigset_t set,old;
	sigemptyset(&set);
	sigaddset(&set,SIGINT);
	sigaddset(&set,SIGQUIT);
	sigaddset(&set,60);
	sigprocmask(SIG_SETMASK,&set,&old);
	sleep(20);
	printf("mask over\n");
	sigset_t pend;
	sigpending(&pend);
	if(sigismember(&pend,SIGINT))
		printf("signo 2 had come.\n");
	if(sigismember(&pend,SIGQUIT))
		printf("signo 3 had come.\n");
	if(sigismember(&pend,60))
		printf("signo 60 had come.\n");
	sigprocmask(SIG_SETMASK,&old,NULL);
}
